Old/New IP - Logic Redo
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi all,
This is something I noticed recently with potential connection interruptions which could occur which the original older code checked for!
https://github.com/OpenVPN/openvpn/pull/910
There was an update pushed earlier this year which undid some important logic in terms of learning/unlearning the ifconfig IP address. The older original code would check that the new/old IPs don't match first before performing that logic. I believe this was important and correct because it could cause connection interruptions during the learn/unlearn process if the IP address has stayed the same!
``` commit 5e4c9a69eaf9d32e85613bd71ed219fdbb062d34 Author: Marco Baffo <[email protected]...> Date: Fri Oct 17 22:19:12 2025 +0200 ... -update_vhash(struct multi_context *m, struct multi_instance *mi, const char *old_ip, const char *old_ipv6) +update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6) { - struct in_addr addr; - struct in6_addr new_ipv6; - - if ((mi->context.options.ifconfig_local && (!old_ip || strcmp(old_ip, mi->context.options.ifconfig_local))) - && inet_pton(AF_INET, mi->context.options.ifconfig_local, &addr) == 1) + if (new_ip) { ```
Thanks,
Jon C
Hi,
Quoted 4 lines · Jon Chiappetta via Openvpn-devel
This is something I noticed recently with potential connection interruptions which could occur which the original older code checked for!
Yeah, but, no.
Since our code is single-threaded, there is no time frame between "unlearn" and "relearn" where a packet could come in and be dropped, due to "address not known".
So yes, on a PUSH_UPDATE with "the same ifconfig again", we do more work than we would have to do, but it has no adverse effects - and if you are worried about that, then do not send PUSH_UPDATE with unchanged configs (given that the client would do a full tun restart on receiving PUSH_UPDATE, this has way more impact than on the server).
Quoted 6 lines
There was an update pushed earlier this year which undid some important logic in terms of learning/unlearning the ifconfig IP address. The older original code would check that the new/old IPs don't match first before performing that logic. I believe this was important and correct because it could cause connection interruptions during the learn/unlearn process if the IP address has stayed the same!
The older code did not do proper unlearning at all, so was obviously not correct.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Hi Gert,
Yes, that is correct, it does impact the multi-threaded operation, however, the older logic has a strcmp between the old IP and the new IP before performing the learn and unlearn logic in the update_vhash function which is what SHOULD happen, this is important and correct. Why would you want to waste cycles and operations doing that when the IPs haven't even changed or differed in value? It doesn't make any logical sense either way even in single threaded operation...
Thanks,
Jon C
Quoted 47 lines · Gert Doering
Hi,
Quoted 2 lines · Jon Chiappetta via Openvpn-devel
This is something I noticed recently with potential connection interruptions which could occur which the original older code checked
for!
Quoted 2 lines
Yeah, but, no.
Since our code is single-threaded, there is no time frame between "unlearn" and "relearn" where a packet could come in and be dropped, due to "address not known".
So yes, on a
PUSH_UPDATEwith "the same ifconfig again", we do more work than we would have to do, but it has no adverse effects - and if you are worried about that, then do not sendPUSH_UPDATEwith unchanged configs (given that the client would do a full tun restart on receivingPUSH_UPDATE,
this has way more impact than on the server).Quoted 4 lines
There was an update pushed earlier this year which undid some important logic in terms of learning/unlearning the ifconfig IP address. The older original code would check that the new/old IPs don't match first before performing that logic. I believe this was important and correct because
it
Quoted 2 lines
could cause connection interruptions during the learn/unlearn process if the IP address has stayed the same!
The older code did not do proper unlearning at all, so was obviously not correct.
gert
--
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never
doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh
MistressGert Doering - Munich, Germany
[email protected]...
*strcmp(old_ip, mi->context.options.ifconfig_local) !*
Quoted 64 lines · Jon Chiappetta
Hi Gert,
Yes, that is correct, it does impact the multi-threaded operation, however, the older logic has a strcmp between the old IP and the new IP before performing the learn and unlearn logic in the
update_vhashfunction which is what SHOULD happen, this is important and correct. Why would you want to waste cycles and operations doing that when the IPs haven't even changed or differed in value? It doesn't make any logical sense either way even in single threaded operation...Thanks,
Jon CQuoted 47 lines · Gert Doering
Hi,
Quoted 2 lines · Jon Chiappetta via Openvpn-devel
This is something I noticed recently with potential connection interruptions which could occur which the original older code checked
for!
Quoted 2 lines
Yeah, but, no.
Since our code is single-threaded, there is no time frame between "unlearn" and "relearn" where a packet could come in and be dropped, due to "address not known".
So yes, on a
PUSH_UPDATEwith "the same ifconfig again", we do more work than we would have to do, but it has no adverse effects - and if you are worried about that, then do not sendPUSH_UPDATEwith unchanged configs (given that the client would do a full tun restart on receivingPUSH_UPDATE,
this has way more impact than on the server).Quoted 4 lines
There was an update pushed earlier this year which undid some important logic in terms of learning/unlearning the ifconfig IP address. The older original code would check that the new/old IPs don't match first before performing that logic. I believe this was important and correct because
it
Quoted 2 lines
could cause connection interruptions during the learn/unlearn process if the IP address has stayed the same!
The older code did not do proper unlearning at all, so was obviously not correct.
gert
--
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never
doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh
MistressGert Doering - Munich, Germany
[email protected]...
Hi,
Quoted 7 lines · Jon Chiappetta
Yes, that is correct, it does impact the multi-threaded operation, however, the older logic has a strcmp between the old IP and the new IP before performing the learn and unlearn logic in the
update_vhashfunction which is what SHOULD happen, this is important and correct. Why would you want to waste cycles and operations doing that when the IPs haven't even changed or differed in value? It doesn't make any logical sense either way even in single threaded operation...
The operational model underlying here is "you send an update when you want to change something", so spending brain & code on "verify that there is an actual change, and skip the update if not" is not effort well spent (also, the client does a full tun restart, which takes much longer than the server side - this is what would need optimizing first ;-) ).
The code, as it is now, is nice and compact, easy to read, and does what is supposed to do.
We can come back to this in the "after 2.7.0 release" timeframe when we open the tree for "refactor and improve code style and details" changes again - right now, we need to focus on actual bugfixes.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Makes sense, thanks Gert, I've been trying to track, when I can, some of the work going into the 2.7 release, I understand you folks have priorities in place already, I don't want to interrupt or delay you all :) I'm not an expert yet on all the different code paths, esp. when it comes to the push and pull options and edge cases involved. I didn't know about that client side full tun restart procedure but if you have any links about it I'd be interested to try and read through the code - otherwise I can try to search for it if I can find some relevant keywords to look for :)
Thanks again as always,
Jon C
Quoted 40 lines · Gert Doering
Hi,
Quoted 1 line · Jon Chiappetta
Yes, that is correct, it does impact the multi-threaded operation,
however,
Quoted 3 lines
the older logic has a strcmp between the old IP and the new IP before performing the learn and unlearn logic in the
update_vhashfunction which is what SHOULD happen, this is important and correct. Why would you wantto
Quoted 1 line
waste cycles and operations doing that when the IPs haven't even changed
or
Quoted 2 lines
differed in value? It doesn't make any logical sense either way even in single threaded operation...
The operational model underlying here is "you send an update when you want to change something", so spending brain & code on "verify that there is an actual change, and skip the update if not" is not effort well spent (also, the client does a full tun restart, which takes much longer than the server side - this is what would need optimizing first ;-) ).
The code, as it is now, is nice and compact, easy to read, and does what is supposed to do.
We can come back to this in the "after 2.7.0 release" timeframe when we open the tree for "refactor and improve code style and details" changes again - right now, we need to focus on actual bugfixes.
gert
--
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never
doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh
MistressGert Doering - Munich, Germany
[email protected]...